package org.pirx.abstraction.byinterfaces;

import org.pirx.annotations.observer;
import org.pirx.annotations.mutator;

import java.util.List;
import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: tonyx
 * Date: Apr 20, 2008
 * Time: 5:54:06 PM
 * To change this template use File | Settings | File Templates.
 */
public class ArrayListStackImpl implements StackInterface {
    protected List list = new ArrayList();

    public synchronized
    @mutator
    void putElement(Object object) {
        list.add(object);
    }

    public
    @observer
    Object topElement() {
        if (list.size() > 0)
            return list.get(list.size() - 1);
        return null;
    }

    public
    @mutator
    void dropElement() {
        if (list.size() > 0)
            list.remove(list.size() - 1);
    }

}
